<?php

namespace app\index\model;

use think\Model;

class Shot_versions extends Model
{

    protected $hidden = ['id', 'shot_id', 'file_md5'];
    protected $autoWriteTimestamp = 'datetime';

    public static function get_data($data='')
    {
        return self::where($data)->order('id desc')->select();
    }

    public static function get_count($data='')
    {
        return self::where($data)->count();
    }

    public static function add_data()
    {
       $data_count = self::where(['version_num'=>input('version_num'),'shot_id'=>input('shot_id')])->count();
        if(!$data_count){
            $data =input() ;
            $data['create_time'] = date("Y-m-d H:i:s") ; // 
            return [1 , self::strict(false)->insert($data)];
        }else{
            return [0 , "data is repeat"];
        }
    }

    public static function update_data($data)
    {
        return self::update($data);
    }

     public static function delete_data($data='')
    {
        return self::where($data)->delete();
    }
}